<body>
<div class="bjy-admin-nav">
	<i class="fa fa-home"></i> 首页
	&gt;
	用户组列表
	&gt;
	分配权限
</div>
<h1 class="text-center">为<span style="color:red"> <{$group.title}> </span>分配权限</h1>
<table class="table table-striped table-bordered table-hover table-condensed">
	<{volist name="list" id="vo"}>
		<{if condition="empty($vo._data)"}>
			<tr class="b-group">
				<th width="10%">
					<label>
						<{$vo.title}>
						<input type="checkbox" name="rule_ids" value="<{$vo.id}>" <{if condition="in_array($vo.id,$group['rules'])"}> checked <{/if}> onclick="checkAll(this)">
					</label>
				</th>
				<td></td>
			</tr>
		<{else/}>
			<tr class="b-group">
				<th width="10%">
					<label>
						<{$vo.title}>
						<input type="checkbox" name="rule_ids" value="<{$vo.id}>" <{if condition="in_array($vo.id,$group['rules'])"}> checked <{/if}> onclick="checkAll(this)">
					</label>
				</th>
				<td class="b-child">
					<{volist name="$vo._data" id="item"}>
						<table class="table table-striped table-bordered table-hover table-condensed">
							<tr class="b-group">
								<th width="10%">
									<label>
										<{$item.title}>
										<input type="checkbox" name="rule_ids" value="<{$item.id}>" <{if condition="in_array($item.id,$group['rules'])"}> checked <{/if}> onclick="checkAll(this)">
									</label>
								</th>
								<td>
									<{if condition="!empty($item._data)"}>
										<{volist name="$item._data" id="items"}>
											<label>
												&emsp; <{$items.title}> <input type="checkbox" name="rule_ids" value="<{$items.id}>" <{if condition="in_array($items.id,$group['rules'])"}> checked <{/if}>>
											</label>
										<{/volist}>
									<{/if}>	
								</td>
							</tr>
						</table>
					<{/volist}>
				</td>
			</tr>
		<{/if}>		
	<{/volist}>
	<tr>
		<th></th>
		<td>
			<input class="btn btn-success submit" type="button" value="提交">
		</td>
	</tr>
</table>
<script>
function checkAll(obj){
    $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
}

$(function(){
    $('.submit').click(function(){
    	var formdata = $("input[name]").serialize();
    	$.post('',{formdata},function(data){
            if(data.code){
            	alert(data.msg);
            	location.href="<{:url('group')}>";
            }else{
                alert(data.msg);
            }
        },'json');
    })
})
</script>
</body>
